# -*- coding: utf-8 -*- 
# @Time : 2020-11-24 22:09 
# @Author : derek.zhang 
# @File : urls.py 
# @Software: PyCharm
from django.contrib.auth.decorators import login_required
from django.urls import path

from deploy.deploy_view import PublishView, DeployView, OperateView, HistoryView
from deploy.report_views import DeployCountView, get_deploy_count, get_app_deploy_count, AppDeployCountView
from deploy.upload_views import DeployVersionUploadView, fileupload
from deploy.views import DeployCreaeView, DeployListView, jenkins_build, jenkins_status, update_deploypool_jenkins, \
    DeployDetailView

app_name = 'deploy'

urlpatterns = [
    path('create/', login_required(DeployCreaeView.as_view()), name='create'),
    path('list/',login_required(DeployListView.as_view()), name='list'),
    path('jenkins_build/', jenkins_build, name='jenkins_build'),
    path('jenkins_status/', jenkins_status, name='jenkins_status'),
    path('update_deploypool_jenkins/', update_deploypool_jenkins, name='update_deploypool_jenkins'),
    path('view/<slug:pk>/', login_required(DeployDetailView.as_view()), name='detail'),
    path('publish/', login_required(PublishView.as_view()), name='publish'),
    path('deploy/<slug:app_name>/<slug:deploy_version>/<slug:env>/', login_required((DeployView.as_view())),
         name='deploy'),
    # path(r'deploy-cmd/',deploy_cmd, name='deploy_cmd'),
]

# deploy
urlpatterns += [
    path('publish/', login_required(PublishView.as_view()),
         name='publish'),
    path('deploy/<slug:app_name>/<slug:deploy_version>/<slug:env>/',
         login_required(DeployView.as_view()),
         name='deploy'),
    # path(r'deploy-cmd/', deploy_cmd, name="deploy-cmd"),

    path('operate/', login_required(OperateView.as_view()),
         name='operate'),
    path('history/', login_required(HistoryView.as_view()),
             name='history'),

]

urlpatterns += [
    path('get_deploy_count/', get_deploy_count,
         name='get_deploy_count'),
    path('get_app_deploy_count/', get_app_deploy_count,
         name='get_app_deploy_count'),
    path('deploy_count/', DeployCountView.as_view(),
         name='deploy_count'),
    path('app_deploy_count/', AppDeployCountView.as_view(),
         name='app_deploy_count'),
]



urlpatterns += [
    path('upload/', DeployVersionUploadView.as_view(),
         name='upload'),
    path('file_upload/', fileupload, name='file_upload')
]